import os
import pathlib
import shutil
from cjc.tools.increment_path import increment_path, last_path

names = ['smile'] #'sex', 'age','head',

train_path = './runs/train'
target_weight_path = './cjc/weights'


def copy(_name):
    target_path = f'{target_weight_path}/{_name}.pt'
    sourcefolder = last_path(train_path,_name)
    best_source_path = f'{train_path}/{sourcefolder}/weights/best.pt'
    pp= pathlib.Path(target_path)
    if pp.exists():
        os.remove(target_path)
    print(best_source_path)
    shutil.copy(best_source_path,target_path)
    # print(best_source_path)



if __name__ == '__main__':

    for n in names:
        copy(n)

